﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Xml.XPath;

namespace WinSCP.API
{
#if DEBUG
    /// <summary>
    /// For development testing, change the project type to "Console Application" to use.
    /// </summary>
    public class TestProgram
    {
        private static string BINARY_PATH = "C:\\WinSCP.com";
        private static string LOG_PATH = "C:\\Log.xml";

        public static void Main(string[] args)
        {
            Console.WriteLine("Ready to begin, press [ENTER].");
            Console.ReadLine();

            Console.Write("Starting Client... ");

            Client scp = new Client(
                System.Net.IPAddress.Parse("216.52.184.54"),
                66,
                "root",
                "tx4&)@4",
                BINARY_PATH,
                LOG_PATH);
            
            Console.WriteLine("done.");
            Console.WriteLine();

            string pwd = scp.WorkingFolder;
            Console.Write("Listing contents of {0}... ", pwd);
            List<FileSystemObject> folderContents = scp.GetContentsList();
            Console.WriteLine("done.");

            foreach (FileSystemObject obj in folderContents)
            {
                string line = obj.Filename.PadRight(30) +
                    obj.ObjType.ToString().PadRight(10);

                if (obj.ObjType == FileSystemObject.ObjectType.File)
                    line += obj.Bytes.ToString() + " bytes";

                Console.WriteLine(line);
            }

            Console.WriteLine();
            Console.WriteLine();

            Console.WriteLine("Press [ENTER] to test change folder and long listing.");
            Console.ReadLine();

            Console.Write("Changing folder to /home/admin... ");
            scp.ChangeDirectory("/home/admin");
            Console.WriteLine("done.");

            pwd = scp.WorkingFolder;
            Console.Write("Listing contents of {0}... ", pwd);
            folderContents = scp.GetContentsList();
            Console.WriteLine("done.");

            foreach (FileSystemObject obj in folderContents)
            {
                string line = obj.Filename.PadRight(30) +
                    obj.ObjType.ToString().PadRight(10);

                if (obj.ObjType == FileSystemObject.ObjectType.File)
                    line += obj.Bytes.ToString() + " bytes";

                Console.WriteLine(line);
            }

            Console.WriteLine();
            Console.WriteLine();

            Console.WriteLine("All operations completed, press [ENTER] to exit.");
            Console.ReadLine();

            Environment.Exit(0);
        }
    }
#endif

}
